package com.wall.haven;

import com.wall.haven.config.SystemConfigCache;
import com.wall.haven.service.IBanImageService;
import com.wall.haven.service.ISystemConfigService;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 初始化
 */
@Component
@Order(value = 1)
public class AfterRunner implements ApplicationRunner {

    private final IBanImageService banImageService;
    private final ISystemConfigService systemConfigService;
    private final SystemConfigCache systemConfigCache;

    public AfterRunner(IBanImageService banImageService, ISystemConfigService systemConfigService, SystemConfigCache systemConfigCache) {
        this.banImageService = banImageService;
        this.systemConfigService = systemConfigService;
        this.systemConfigCache = systemConfigCache;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        banImageService.init();
        systemConfigService.init();
        systemConfigCache.load();
    }
}